# import pandas as pd
import tushare as ts


def get_annual_profit(maotai, geli, start_date, end_date):
    df_maotai = ts.get_hist_data(maotai, start=start_date, end=end_date)
    df_geli = ts.get_hist_data(geli, start=start_date, end=end_date)
    maotai_annual_profit = (1 + (df_maotai.head(1)['close'].values[0] /
                                 df_maotai.tail(1)['close'].values[0] - 1))**(
                                     250 / df_maotai.shape[0]) - 1
    geli_annual_profit = (1 + (df_geli.head(1)['close'].values[0] /
                               df_geli.tail(1)['close'].values[0] - 1))**(
                                   250 / df_geli.shape[0]) - 1
    print('茅台年化收益: ', maotai_annual_profit, u' 格力电器年化收益: ', geli_annual_profit)


get_annual_profit('600519', '000651', '2019-06-01', '2019-11-17')
